library(tidyverse)
library(dplyr)
library(stringr)
library(lubridate)
library(sf)
library(leaflet)
library(leafpop)
library(htmltools)
library(scales)
library(highcharter)
library(reactable)
varnames <- c('TI.Application.Number',
'Program',
'Calculated.Total.System.Size',
'Customer.Type',
'Third.Party.Ownership',
'Contractor.Company',
'Electric.Utility.Name',
'Premise.........................Zip',
'County......................Code',
'Interconnection',
'Acceptance.Date')
varreplace <- c('id',
'program',
'capacity',
'segment',
'third',
'contractor',
'utility',
'zip',
'county',
'type',
'date')
nj <- do.call(rbind,
lapply(list.files(path = "raw data/NJ/solar"), read.csv)) %>%
select(varnames) %>%
rename_at(vars(varnames), ~varreplace) %>%
mutate(date = dmy(date),
capacity = as.numeric(gsub(",","", capacity)),
quarter = zoo::as.yearqtr(date, format = "%Y-%m-%d"),
segment_x = case_when(
type == 'Community Solar' ~ 'Community Solar',
segment == 'Residential' ~ 'Residential',
TRUE ~ 'Non-Residential'),
utility = case_when(
grepl("pse", utility, ignore.case = TRUE) ~ "PSEG",
grepl("ac electric", utility, ignore.case = T) ~ "AC Electric",
grepl("jcp", utility, ignore.case = T) ~ "JCP&L",
grepl("rockland", utility, ignore.case = T) ~ 'O&R',
TRUE ~ 'Other (muni/co-op)'
)) %>%
filter(type != 'Grid Supply') %>%
distinct()
nj_quarter <- nj %>%
filter(date >= '2020-07-01') %>%
group_by(segment_x, quarter) %>%
summarise(cap = sum(capacity)/1000)
nj_seg <- nj %>%
filter(quarter == '2021 Q2') %>%
mutate(res_cap = if_else(segment_x == 'Residential', capacity, 0),
com_cap = if_else(segment_x == 'Non-Residential', capacity, 0),
cs_cap = if_else(segment_x == 'Community Solar', capacity, 0),
month = month(date))
nj_com_seg <- nj_seg %>%
filter(segment_x == 'Non-Residential') %>%
mutate(segment = as.factor(case_when(
grepl('School', segment) ~ 'School',
TRUE ~ segment
))) %>%
group_by(segment) %>%
summarise(cap = sum(capacity),
n = n(),
mean = mean(capacity)) %>%
ungroup() %>%
mutate(share = cap/sum(cap))
New Jersey added r round(sum(nj_seg$capacity)/1000,2) MW of new distributed solar capacity to the interconnection queue in Q2 2021
nj_quarter %>%
hchart('column', hcaes(x = as.factor(quarter), y = round(cap,2), group = segment_x)) %>%
hc_colors(c('#F37325', '#2490BD', "#47B970", '#1A2B40', '#b7b7b7', '#800000','#F8AA1A')) %>%
hc_plotOptions(series = list(stacking = 'normal')) %>%
hc_xAxis(title = '', labels = list(step = 1) #, minorTickInterval
) %>%
hc_yAxis(title = list(text = 'Quarterly capacity (MW)'), style = list(fontSize = "5.0vh"))
Of the r round(sum(nj_seg\(capacity[nj_seg\)segment_x == ‘Non-Residential’]/1000),2) MW of new capacity that was Non-Residential…
for (i in levels(nj_com_seg$segment)) {
cat("- ", "**", round(nj_com_seg$cap[nj_com_seg$segment == i]/1000,2), "**", " MW was ", i, sep = "")
cat("\n")
}
- 163.8 MW was Commercial
- 0.42 MW was Farm
- 10.06 MW was Government Facility
- 1.84 MW was Municipality
- 9.57 MW was Non Profit
- 30.48 MW was Public University
- 18.87 MW was School
nj_com_seg %>%
hchart('pie', hcaes(x = segment, y = round(cap/1000,2)), name = "Capacity (MW)") %>%
hc_colors(c( '#2490BD', '#800000', '#F37325', "#47B970", '#1A2B40', '#b7b7b7', '#F8AA1A'))
Where was new capacity added in Q2 2021?
nj_map <- nj_seg %>%
mutate(geoid2 = as.numeric(substr(zip,1,5))) %>%
filter(!geoid2 == 16807|!geoid2 == 17047) %>%
group_by(geoid2) %>%
summarise(cap = sum(capacity)/1000)
njmap <- st_read('raw data/NJ/acs2019_5yr_B01003_86000US08403.shp') %>%
mutate(geoid2 = as.numeric(substr(geoid,8,12))) %>%
filter(!name == 'New Jersey',
!geoid2 == 10990, !geoid2 == 10969) %>%
left_join(nj_map, by = 'geoid2') # join capacity data to shapefile
zip <- read.csv('raw data/uszips.csv') %>% # dataset from US census bureau that matches zip codes to town names - to be used in interactive map popup
select(zip, city) %>%
rename('geoid2' = 'zip')
nj_int <- left_join(njmap, zip, by = 'geoid2') %>%
mutate(cap = round(cap*1000,0),
cap2 = if_else(is.na(cap),0,cap))
map_pal <- c('#e0f1f9', '#2490BD')
pal <- colorNumeric(palette = map_pal, domain = nj_int$cap, na.color = '#FFFFFF') # palette function for choropleth map
labels <- sprintf("<strong>%s</strong><br/> Zip code: %s<br/> Capacity Q2 2021: %s kW",
nj_int$city, paste(0, nj_int$geoid2, sep = ""), comma(nj_int$cap2)) %>%
lapply(HTML) # function for popup labels
map_int <- leaflet(nj_int) %>% addTiles()
map_int %>% addPolygons(fillColor = ~pal(cap),
weight = 0.5,
opacity = 1,
color = "gray",
dashArray = "3",
fillOpacity = 0.7,
highlightOptions = highlightOptions(color = '#2a2a2a',
weight = 2,
dashArray = "",
fillOpacity = 0.7,
bringToFront = T),
label = labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto",
opacity = 0.75)) %>%
addProviderTiles('Esri.WorldGrayCanvas')